package com.qf.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.ssm.mapper.StoreMapper;
import com.qf.ssm.po.Store;
import com.qf.ssm.qo.StoreEmpQo;
import com.qf.ssm.qo.StoreQo;
import com.qf.ssm.service.StoreService;
import com.qf.ssm.utlis.ImageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.*;
import javax.servlet.descriptor.JspConfigDescriptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;

@Service
public class StoreServiceImpl implements StoreService {
    @Autowired
    StoreMapper storeMapper;
    @Autowired
    ServletContext servletContext;

    @Override
    public Integer addStore(Store store) {
        return storeMapper.addStore(store);
    }

    @Override
    public PageInfo<Store> list(int page, int size, StoreQo storeQo) {
        PageInfo<Store> pageInfo = PageHelper.startPage(page,size).doSelectPageInfo(()-> storeMapper.selectLimitByKeyword(storeQo.getDelStatus(),storeQo.getKeyWord()));
        return pageInfo;
    }

    @Override
    public Integer deleteStoreByName(String storeName) {
        return storeMapper.delStoreByName(storeName);
    }

    @Override
    public Integer modification(Store store) {
        return storeMapper.modifyMsg(store);
    }

    @Override
    public List<StoreEmpQo> searchEmp(String storeName) {
        return storeMapper.selectStoreAndEmpByStoreName(storeName);
    }

    @Override
    public String getImage(String location) {
        return ImageUtils.getImage(location);
    }


}
